home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / bitblt.c < prev    next >
Text File  |  1993-12-06  |  2KB  |  76 lines

  1. /**
  2.  ** BITBLT.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "grx.h"
  25. #include "libgrx.h"
  26. #include "clipping.h"
  27.  
  28. void GrBitBlt(GrContext *dst,int x,int y,
  29.           GrContext *src,int x1,int y1,int x2,int y2,int oper)
  30. {
  31.     int oldx,oldy;
  32.     int msflag = FALSE;
  33.  
  34.     if(dst == NULL) dst = CURC;
  35.     if(src == NULL) src = CURC;
  36.     SORT2(x1,x2);
  37.     SORT2(y1,y2);
  38.     oldx = x1;
  39.     oldy = y1;
  40.     CLIPBOXTOCONTEXT(src,x1,y1,x2,y2);
  41.     x += (x1 - oldx);
  42.     y += (y1 - oldy);
  43.     x2 += ((oldx = x) - x1);
  44.     y2 += ((oldy = y) - y1);
  45.     CLIPBOX(dst,x,y,x2,y2);
  46.     x1 += (x - oldx);
  47.     y1 += (y - oldy);
  48.     if(_GrMouseDrawn) {
  49.         GrContext *cxt = NULL;
  50.         int mx1,my1,mx2,my2;
  51.         if(src->gc_onscreen) {
  52.         cxt = src->gc_root ? src->gc_root : src;
  53.         mx1 = x1  + src->gc_xoffset;
  54.         my1 = y1  + src->gc_yoffset;
  55.         mx2 = mx1 + x2 - x;
  56.         my2 = my1 + y2 - y;
  57.         }
  58.         if(dst->gc_onscreen) {
  59.         cxt = dst->gc_root ? dst->gc_root : dst;
  60.         mx1 = MIN(mx1,x  + dst->gc_xoffset);
  61.         my1 = MIN(my1,y  + dst->gc_yoffset);
  62.         mx2 = MAX(mx2,x2 + dst->gc_xoffset);
  63.         my2 = MAX(my2,y2 + dst->gc_yoffset);
  64.         }
  65.         if(cxt) msflag = (*_GrMouseBlock)(cxt,mx1,my1,mx2,my2);
  66.     }
  67.     _GrPixCopy(dst,PIX_ADDR(dst,x,y),
  68.         src,PIX_ADDR(src,x1,y1),
  69.         (x2 - x + 1),
  70.         (y2 - y + 1),
  71.         oper
  72.     );
  73.     if(msflag) (*_GrMouseUnBlock)(msflag);
  74. }
  75.  
  76.